/**
* Created by czg on 2019/1/9 0009 Time: 16:43 .
*/

<template lang="html">
    <div class="bg">
        <div class="detail-container" v-wechat-title='$route.meta.title=this.title' img-set='none' ref="box" :style="{'height':boxh+'px','width':boxw+'px'}">
            <div v-if="isStatic" v-html="lists"></div>
        </div>
    </div>

</template>
<script>
import axios from 'axios'
export default {
  name: 'detail',
  created () {
    this.getContent();
    this.clientHeight = `${document.documentElement.clientHeight}`;
    this.clientWidth=`${document.documentElement.clientWidth}`;
    this.boxh=this.clientHeight ;
    this.boxw=this.clientWidth;
  },
  methods: {
    getContent () {
      this.actID = this.$route.query.id
      axios.post('https://vip.gznewpark.com/dist/admin/public/index.php/wx/Shop/storeActivity').then(res => {
        this.contentList = res.data.result
        const index = this.contentList.findIndex(item => item.id === this.actID)
        this.title = this.contentList[index].title
        this.lists = this.contentList[index].content
        console.log(this.contentList[index])
        this.url = this.contentList[index].url
        const isUrl = this.contentList[index].is_url
        if (isUrl == 0) {
          this.isStatic = true
        } else {
          window.location.href = this.url
          window.history.pushState('', '', '#')
          window.addEventListener('popstate',function(e){
            window.location.replace('/index')
          })
        }
      })
    }
  },
  data () {
    return {
      isStatic:false,
      actID: Number,
      contentList: [],
      lists:[],
      title: '',
      clientHeight:'',
      clientWidth:'',
      boxh:'',
      boxw:''
    }
  }
}
</script>

<style lang="less">
    .bg{
        background: url("../../static/bg.png") no-repeat center center;
        background-size: cover;
        background-attachment: fixed;
        overflow: auto;
        box-sizing: border-box;
        padding:0px!important;
    }
    .detail-container{
        box-sizing: border-box;
        padding: 0px!important;
        width: 100%;
        height: 100%;
        overflow-y: scroll;
    }
        .detail-container img {
            width: 100%;
            height: auto;
        }
</style>
